package com.yang.springboot.web;

import com.yang.springboot.service.IStudentService;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author yanwei.yang
 * @date 2021/11/16 16:55
 * @description:
 */
@RestController
public class StudentController {


    @Resource
    private RedisTemplate<Object, Object> redisTemplate;

    @Resource
    private IStudentService studentService;


    @GetMapping("student")
    public Object student(Integer id) {
        return studentService.getById(id);
    }

    @RequestMapping("put")
    public Object put(String key, String value) {
        redisTemplate.opsForValue().set(key, value);
        return "success";
    }


    @RequestMapping("get")
    public Object get(String key) {
        return redisTemplate.opsForValue().get(key);
    }
}
